import request from "@/api/config";
import { AxiosPromise } from 'axios';
import {PORT} from "@/leadmall/api/config/servicePort";
import { DepartmentVO, DepartmentForm, DepartmentQuery } from '@/leadmall/api/department/types';

/**
 * 查询部门组织列表
 * @param query
 * @returns {*}
 */

export const listDepartment = (query?: DepartmentQuery): AxiosPromise<DepartmentVO[]> => {
  return request({
    url: PORT +'/leadmall/department/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询部门组织详细
 * @param id
 */
export const getDepartment = (id: string | number): AxiosPromise<DepartmentVO> => {
  return request({
    url: PORT +'/leadmall/department/' + id,
    method: 'get'
  });
};

/**
 * 新增部门组织
 * @param data
 */
export const addDepartment = (data: DepartmentForm) => {
  return request({
    url: PORT +'/leadmall/department',
    method: 'post',
    data: data
  });
};

/**
 * 修改部门组织
 * @param data
 */
export const updateDepartment = (data: DepartmentForm) => {
  return request({
    url: PORT +'/leadmall/department',
    method: 'put',
    data: data
  });
};

/**
 * 删除部门组织
 * @param id
 */
export const delDepartment = (id: string | number | Array<string | number>) => {
  return request({
    url: PORT +'/leadmall/department/' + id,
    method: 'delete'
  });
};
